package transformVolOne;


/**
 * Public inner class, which is used to create the four corners of a rectangle
 * @author MacDerson Louis
 *
 */
public class Box{
	private boolean color1; //a t/f value that represents the boxes current color;
	private boolean color2;
	private boolean color3;
	private boolean color4;
	private int index;

	/**
	 * initialize color to 0, indicating that no color has been set
	 */
	public Box(){			
		color1 = false;
		color2 = false;
		color3 = false;
		color4 = false;

		index = -1;
	}
	
	public int[] getClause(){
		int[] clause = new int[4];
				
		if(color1)
			clause[0] = 1;
		else
			clause[0] = -1;
		if(color2)
			clause[1] = 2;
		else
			clause[1] = -2;
		if(color3)
			clause[2] = 3;
		else
			clause[2] = -3;
		if(color4)
			clause[3] = 4;
		else
			clause[3] = -4;
		
		return clause;
	}

	/**
	 * returns the color of this Box(from 1 - 4)
	 * representing 1 of 4 colors. 
	 * @return
	 */
	public int getColor(){
		if(color1)
			return 1;
		if(color2)
			return 2;
		if(color3)
			return 3;
		if(color4)
			return 4;
		
		return 0;
	}

	/**
	 * sets the color of this Box
	 * @param color
	 */
	public void setColor(int num, boolean color){			
		switch(num){
		case 1: color1 = color;
		break;
		case 2: color2 = color;
		break;
		case 3: color3 = color;
		break;
		case 4: color4 = color;
		break;
		}
	}

	/**
	 * return the Boxe's index if located in an array
	 * essentially returns its address in an array
	 * @return index of referencing array, -1 if not stored in an array.
	 */
	public int getIndex(){
		return index;
	}

	/**
	 * sets the value of the index for any referencing array
	 * essentially stores it's location in an array.
	 * @param num
	 */
	public void setIndex(int num){
		index = num;
	}	
}
